package pwd.allen.service.stub;

import pwd.allen.service.IHelloService;

import java.util.Map;

/**
 * 实现IHelloService的存根，可以在调用远程服务前后自定义逻辑
 *      必须实现以服务作为参数的构造器
 *
 * @author 门那粒沙
 * @create 2019-10-16 21:51
 **/
public class HelloServiceStub implements IHelloService {

    private final IHelloService helloService;

    /**
     * 必须有该构造器
     * @param helloService
     */
    public HelloServiceStub(IHelloService helloService) {
        this.helloService = helloService;
    }

    @Override
    public String sayHello(String name) {
        System.out.println("this is HelloServiceStub");
        return helloService.sayHello(name);
    }

    @Override
    public Map getMap(Map<String, Object> map) {
        System.out.println("this is HelloServiceStub");
        return helloService.getMap(map);
    }

}
